﻿//===============================================================================
// 功能描述：数据库访问工厂类，根据配置文件动态创建数据库访问类（OleDbDataAccess的类或SQLServerDataAccess的类）。

// 创建标识：张林 2007-09-07

// 修改标识：

// 修改描述：
//===============================================================================
using System.Reflection;
using System.Configuration;

namespace PatNetShop.DataAccessFactory
{

    /// <summary>
    /// This class is implemented following the Abstract Factory pattern to create the DataAccess implementation
    /// specified from the configuration file
    /// </summary>
    public sealed class DataAccess
    {

        private static readonly string path = ConfigurationManager.AppSettings["WebDataAccess"];

        private DataAccess() { }

        public static PatNetShop.DBInterface.ISample CreateSample()
        {
            string className = path + ".Sample";
            return (PatNetShop.DBInterface.ISample)Assembly.Load(path).CreateInstance(className);
        }

    }
}
